package org.jks.service;

import java.util.ArrayList;
import java.util.List;

import org.jks.constant.Constants;
import org.jks.model.WorkType;
import org.springframework.stereotype.Service;
@Service
public class WorkTypeService extends EntityService<WorkType>{
	
	public WorkTypeService(){
		MODEL_NAME = WorkType.class.getSimpleName();
		CLASS_NAME = WorkType.class;
	}
	
	public WorkType findByName(String name){
		List<Object> params = new ArrayList<Object>();
		params.add(name);
		return get("from WorkType where Name=?", params);
	}
	
	public WorkType findByType(int workType){
		if(workType == org.jks.constant.WorkType.FX_WORK){
			return findByName(Constants.STR_FX_WORK);
		}
		else if(workType == org.jks.constant.WorkType.CD_WORK){
			return findByName(Constants.STR_CD_WORK);
		}
		else if(workType == org.jks.constant.WorkType.TS_WORK){
			return findByName(Constants.STR_TS_WORK);
		}
		return null;
	}
}
